#include<bits/stdc++.h>
using namespace std;
//const int maxn=;
long long a,b,n,l,r;

int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	if(r-l>=n){
		cout<<n-1;
	}
	else{
		a=l%n;
		b=r%n;
		if(b>a) cout<<b;
		else cout<<n-1;
	}
	return 0;
}
